/******************************************************************************/
/*                                                                            */
/*  Copyright (c) 2009: ngi-central.org                                       */
/*  All rights reserved.                                                      */
/*                                                                            */
/******************************************************************************/


#include <boost/test/unit_test.hpp>

#include "..\..\include\sgl\scale_invariant_moments.h"

BOOST_AUTO_TEST_SUITE( scale_invariant_moments )


BOOST_AUTO_TEST_CASE( scale_invariant_moments__default_constructor )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta20() == 0 );
	BOOST_CHECK( a.eta11() == 0 );
	BOOST_CHECK( a.eta02() == 0 );
	BOOST_CHECK( a.eta30() == 0 );
	BOOST_CHECK( a.eta21() == 0 );
	BOOST_CHECK( a.eta12() == 0 );
	BOOST_CHECK( a.eta03() == 0 );

	sgl::scale_invariant_moments<> b(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( b.eta20() == 1 );
	BOOST_CHECK( b.eta11() == 2 );
	BOOST_CHECK( b.eta02() == 3 );
	BOOST_CHECK( b.eta30() == 4 );
	BOOST_CHECK( b.eta21() == 5 );
	BOOST_CHECK( b.eta12() == 6 );
	BOOST_CHECK( b.eta03() == 7 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__copy_constructor )
{
	sgl::scale_invariant_moments<> a(
		sgl::scale_invariant_moments<>(1, 2, 3, 4, 5, 6, 7));

	BOOST_CHECK( a.eta20() == 1 );
	BOOST_CHECK( a.eta11() == 2 );
	BOOST_CHECK( a.eta02() == 3 );
	BOOST_CHECK( a.eta30() == 4 );
	BOOST_CHECK( a.eta21() == 5 );
	BOOST_CHECK( a.eta12() == 6 );
	BOOST_CHECK( a.eta03() == 7 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__conversion_copy_constructor )
{
	sgl::scale_invariant_moments<> a(
		sgl::normalized_moments<>(1, 1, 2, 3, 4, 5, 6, 7, 8, 9));

	BOOST_CHECK( a.eta20() == 2 );
	BOOST_CHECK( a.eta11() == 2 );
	BOOST_CHECK( a.eta02() == 1 );
	BOOST_CHECK( a.eta30() == -1 );
	BOOST_CHECK( a.eta21() == -3 );
	BOOST_CHECK( a.eta12() == -5 );
	BOOST_CHECK( a.eta03() == -5 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__copy_assignment )
{
	sgl::scale_invariant_moments<> a;
	a = sgl::scale_invariant_moments<>(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.eta20() == 1 );
	BOOST_CHECK( a.eta11() == 2 );
	BOOST_CHECK( a.eta02() == 3 );
	BOOST_CHECK( a.eta30() == 4 );
	BOOST_CHECK( a.eta21() == 5 );
	BOOST_CHECK( a.eta12() == 6 );
	BOOST_CHECK( a.eta03() == 7 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__swap )
{
	sgl::scale_invariant_moments<> a(
		sgl::scale_invariant_moments<>(1, 2, 3, 4, 5, 6, 7));
	sgl::scale_invariant_moments<> b;

	a.swap(b);

	BOOST_CHECK( a.eta20() == 0 );
	BOOST_CHECK( a.eta11() == 0 );
	BOOST_CHECK( a.eta02() == 0 );
	BOOST_CHECK( a.eta30() == 0 );
	BOOST_CHECK( a.eta21() == 0 );
	BOOST_CHECK( a.eta12() == 0 );
	BOOST_CHECK( a.eta03() == 0 );
	BOOST_CHECK( b.eta20() == 1 );
	BOOST_CHECK( b.eta11() == 2 );
	BOOST_CHECK( b.eta02() == 3 );
	BOOST_CHECK( b.eta30() == 4 );
	BOOST_CHECK( b.eta21() == 5 );
	BOOST_CHECK( b.eta12() == 6 );
	BOOST_CHECK( b.eta03() == 7 );

	b.swap(a);

	BOOST_CHECK( a.eta20() == 1 );
	BOOST_CHECK( a.eta11() == 2 );
	BOOST_CHECK( a.eta02() == 3 );
	BOOST_CHECK( a.eta30() == 4 );
	BOOST_CHECK( a.eta21() == 5 );
	BOOST_CHECK( a.eta12() == 6 );
	BOOST_CHECK( a.eta03() == 7 );
	BOOST_CHECK( b.eta20() == 0 );
	BOOST_CHECK( b.eta11() == 0 );
	BOOST_CHECK( b.eta02() == 0 );
	BOOST_CHECK( b.eta30() == 0 );
	BOOST_CHECK( b.eta21() == 0 );
	BOOST_CHECK( b.eta12() == 0 );
	BOOST_CHECK( b.eta03() == 0 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta20 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta20() == 0 );

	a.eta20() = 1;

	BOOST_CHECK( a.eta20() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta11 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta11() == 0 );

	a.eta11() = 1;

	BOOST_CHECK( a.eta11() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta02 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta02() == 0 );

	a.eta02() = 1;

	BOOST_CHECK( a.eta02() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta30 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta30() == 0 );

	a.eta30() = 1;

	BOOST_CHECK( a.eta30() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta21 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta21() == 0 );

	a.eta21() = 1;

	BOOST_CHECK( a.eta21() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta12 )
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta12() == 0 );

	a.eta12() = 1;

	BOOST_CHECK( a.eta12() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__eta03)
{
	sgl::scale_invariant_moments<> a;

	BOOST_CHECK( a.eta03() == 0 );

	a.eta03() = 1;

	BOOST_CHECK( a.eta03() == 1 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__operator_equality )
{
	sgl::scale_invariant_moments<> a;
	sgl::scale_invariant_moments<> b;

	BOOST_CHECK( a == b );

	sgl::scale_invariant_moments<> c(1, 2, 3, 4, 5, 6, 7);
	sgl::scale_invariant_moments<> d(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( c == d );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__operator_inequality )
{
	sgl::scale_invariant_moments<> a;
	sgl::scale_invariant_moments<> b(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a != b );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi1 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi1() == 4 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi2 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi2() == 20 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi3 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi3() == 260 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi4 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi4() == 244 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi5 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi5() == 61456 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi6 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi6() == 1048 );
}

BOOST_AUTO_TEST_CASE( scale_invariant_moments__calculate_phi7 )
{
	sgl::scale_invariant_moments<> a(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.calculate_phi7() == -352 );
}

BOOST_AUTO_TEST_SUITE_END()

